﻿/*
 *  RetroGlider v1.0
    Copyright (C) 2013 Alexander Blohmé

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace RetroGlider
{
    class CombatEngine
    {
        public int KillCounter = 0;
        WoWEngine wowInfo = new WoWEngine();
        public void StartAttack()
        {
         

        }


        // This function must be run inside a timer
        private void Run()
        {
            wowInfo.InitWoW();
            WalkEngine walky = new WalkEngine();
            // Send walk

            if (walky.ScanForMob())
            {
                walky.StopAllMovement();
                walky.ApproachMob();
                KillMob();  // Run kill function

            }
            else
            {
                // Keep walking
            }
        }


        private void KillMob()
        {
            bool preSpells_Casted = false;

            // player not dead, target not dead and have target
            while (wowInfo.PlayerHealth() > 1 && wowInfo.TargetHealth() > 1 && wowInfo.HaveTarget())
            {
                // process combat here
                if (preSpells_Casted == false)
                {
                    CastPreCombatSpells();
                }
                else
                {
                    CastMainSpells();
                }

            }
            // Check what happend.
            if (wowInfo.PlayerHealth() < 1)
            {
                
                // Player died. Click release and tell the WalkEngine to walk the ghost path
            }
            else if (wowInfo.TargetHealth() < 1 && wowInfo.PlayerHealth() > 1)
            {
                // We killed the target, horray!
                // Make walkengine walk up to the body and do the loot function and tell walkengine to continue its journey.
                KillCounter++;
            }


            // end combat here
           
        }
        private void LootBody()
        {

        }

        private void CastPreCombatSpells()
        {

        }
        private void CastMainSpells()
        {

        }
        private void Rest()
        {

        }

    }
}
